package com.lotter.common.util;

import com.lotter.common.exception.LotterCusException;

/**
 * 公共使用方法
 * @author zhangzechi
 * 
 */
public class CommonUtil {
	
	public static boolean verAccountName(String accountName) throws LotterCusException{
		if(StringUtil.isBlank(accountName))
			return false;
		if(!isChinese(accountName)){
			return false ;
		}
		int number  =  accountName.toCharArray().length;
		
		if(number > 4 || number < 2){
			return false;
		}
		return true;
	}


	 private static boolean isChinese(String strName) {
	        char[] ch = strName.toCharArray();
	        for (int i = 0; i < ch.length; i++) {
	            char c = ch[i];
	            if (isChinese(c)) {
	                continue;
	            }else {
					return false;
				}
	        }
	        return true;
	 }
	 
	 
	 // 根据Unicode编码完美的判断中文汉字和符号
    private static boolean isChinese(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) {
            return true;
        }
        return false;
    }
    

	 
}
